{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": true
   },
   "source": [
    "<h1>大纲<span class=\"tocSkip\"></span></h1>\n",
    "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#如何画表格\" data-toc-modified-id=\"如何画表格-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>如何画表格</a></span><ul class=\"toc-item\"><li><span><a href=\"#储存数据，一次显示\" data-toc-modified-id=\"储存数据，一次显示-1.1\"><span class=\"toc-item-num\">1.1&nbsp;&nbsp;</span>储存数据，一次显示</a></span></li><li><span><a href=\"#显示数据追加更新\" data-toc-modified-id=\"显示数据追加更新-1.2\"><span class=\"toc-item-num\">1.2&nbsp;&nbsp;</span>显示数据追加更新</a></span></li></ul></li><li><span><a href=\"#单元格左对齐显示\" data-toc-modified-id=\"单元格左对齐显示-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>单元格左对齐显示</a></span></li></ul></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 如何画表格\n",
    "1. 设置行字段名称\n",
    "1. 设置列字段名称\n",
    "1. 填充数据\n",
    "1. 显示\n",
    "    1. 控制显示字段的顺序\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 储存数据，一次显示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-04T10:47:48.127370Z",
     "start_time": "2018-05-04T10:47:48.116682Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/iroan/tools/anaconda3/lib/python3.6/site-packages/pandas/core/indexes/api.py:87: RuntimeWarning: '<' not supported between instances of 'int' and 'str', sort order is undefined for incomparable objects\n",
      "  result = result.union(other)\n"
     ]
    }
   ],
   "source": [
    "filename = 'address.wav'\n",
    "stream_len = 12002\n",
    "vad_setting = (2,30)\n",
    "result = '河南省 南阳市 号'\n",
    "is_vad_proces = True\n",
    "\n",
    "\n",
    "filenames.append(filename)\n",
    "stream_lens.append(stream_len)\n",
    "vad_settings.append(vad_setting)\n",
    "results.append('河南省 南阳市 相 县 城关镇 十 号')\n",
    "is_vad_process.append(is_vad_proces)\n",
    "\n",
    "def get_head_data():\n",
    "    return pd.DataFrame({\n",
    "        'A:filename':filename,\n",
    "        'B:len':stream_len,\n",
    "        'C:setting':vad_setting,\n",
    "        'D:result':result,\n",
    "        'E:process ':is_vad_proces\n",
    "    })\n",
    "\n",
    "def get_data():\n",
    "    return pd.DataFrame([filename,stream_len,vad_setting,result,is_vad_proces])\n",
    "\n",
    "\n",
    "import time\n",
    "df = get_head_data()\n",
    "for i in range(2):\n",
    "    t = pd.concat([get_data()])\n",
    "    df = pd.concat([df,t],ignore_index=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 显示数据追加更新"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 单元格左对齐显示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-05-04T10:52:27.545219Z",
     "start_time": "2018-05-04T10:52:27.532889Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A:filename</th>\n",
       "      <th>B:len</th>\n",
       "      <th>C:setting</th>\n",
       "      <th>D:result</th>\n",
       "      <th>E:process</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>address.wav</td>\n",
       "      <td>12002</td>\n",
       "      <td>(2, 30)</td>\n",
       "      <td>河南省 南阳市 号</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>address.wav</td>\n",
       "      <td>12002</td>\n",
       "      <td>(2, 30)</td>\n",
       "      <td>河南省 南阳市 相 县 城关镇 十 号</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    A:filename  B:len C:setting             D:result  E:process \n",
       "0  address.wav  12002   (2, 30)            河南省 南阳市 号        True\n",
       "1  address.wav  12002   (2, 30)  河南省 南阳市 相 县 城关镇 十 号        True"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filename = 'address.wav'\n",
    "stream_len = 12002\n",
    "vad_setting = (2,30)\n",
    "result = '河南省 南阳市 号'\n",
    "is_vad_proces = True\n",
    "\n",
    "filenames = []\n",
    "stream_lens = []\n",
    "vad_settings = []\n",
    "results = []\n",
    "is_vad_process = []\n",
    "\n",
    "filenames.append(filename)\n",
    "stream_lens.append(stream_len)\n",
    "vad_settings.append(vad_setting)\n",
    "results.append(result)\n",
    "is_vad_process.append(is_vad_proces)\n",
    "\n",
    "filenames.append(filename)\n",
    "stream_lens.append(stream_len)\n",
    "vad_settings.append(vad_setting)\n",
    "results.append('河南省 南阳市 相 县 城关镇 十 号')\n",
    "is_vad_process.append(is_vad_proces)\n",
    "\n",
    "df = pd.DataFrame({\n",
    "    'A:filename':filenames,\n",
    "    'B:len':stream_lens,\n",
    "    'C:setting':vad_settings,\n",
    "    'D:result':results,\n",
    "    'E:process ':is_vad_process\n",
    "})\n",
    "\n",
    "# pd.set_option('display.unicode.east_asian_width',True)\n",
    "df\n",
    "# print(df)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda all lib",
   "language": "python",
   "name": "base"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "大纲",
   "title_sidebar": "目录",
   "toc_cell": true,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
